-module(bt_test, [Goal]).
-behaviour(backtrack).
-export([
         test/0,
         is_goal/1,
         children/1,
         log/5
        ]).


%%%  TEST GRAPH 1
%%%
%%%  


%% tg1 describes the graph on p98 of Luger & Stubblefield.
children(a) ->
    [b, c, d];
children(b) ->
    [e, f];
children(c) ->
    [f, g];
children(d) ->
    [];
children(e) ->
    [h, i];
children(f) ->
    [j];
children(g) ->
    [];
children(h) ->
    [];
children(i) ->
    [];
children(j) ->
    [].


root_node() -> a.


is_goal(X) when X == Goal ->
    true;
is_goal(_) ->
    false.


%% Make a simple function which will return true when given Node
%% and false otherwise.
%% make_goal(Node) ->
%%     fun (X) when X == Node -> true;
%%         (_) -> false
%%     end.


log(A, B, C, D, E) ->
    backtrack:full_log(A, B, C, D, E).


test() ->
    backtrack:search(THIS, root_node()). 


%% Test tg1 to find GoalNode and return either the path from the
%% root ('a') to GoalNode or else fail.
%% test(GoalNode) ->
%%     graph_search:backtrack(
%%       a, 
%%       make_goal(GoalNode), 
%%       fun tg1/1, 
%%       fun graph_search:full_log/5
%%       %%fun (fwd, A, B, C, D) -> graph_search:full_log(fwd, A, B, C, D);
%%       %%    (_, _, _, _, _) -> ok 
%%       %%end
%%      ). 
